/**
 * 
 */
package earserpdf;

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpLocation;
import com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpProcessor;

/**
 * <p>Title:EarserPdf</p>
 * <p>Description:TODO</p>
 * @author	xiongf
 * @date	2015年12月8日 下午7:23:11
 * @version 1.0
 */
public class EarserPdf {

	 public static final String SRC = "E:/Workspace/ItextPDFDemo/pdffolder/page229.pdf";
	    public static final String DEST = "E:/Workspace/ItextPDFDemo/pdffolder/page229_removed_content.pdf";
	 
	    public static void main(String[] args) throws Exception {
	        File file = new File(DEST);
	        file.getParentFile().mkdirs();
	        new EarserPdf().manipulatePdf(SRC, DEST);
	    }
	 
	    public void manipulatePdf(String src, String dest) throws Exception {
	        PdfReader reader = new PdfReader(src);
	        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
	        List<PdfCleanUpLocation> cleanUpLocations = new ArrayList<PdfCleanUpLocation>();
	        cleanUpLocations.add(new PdfCleanUpLocation(1, new Rectangle(97f, 405f, 480f, 445f), BaseColor.RED));
	        PdfCleanUpProcessor cleaner = new PdfCleanUpProcessor(cleanUpLocations, stamper);
	        cleaner.cleanUp();
	        stamper.close();
	        reader.close();
	    }

}
